<?php
namespace app\http\middleware;
use app\admin\model\system\Node;
use app\common\constants\AdminConstant;
use \liliuwei\think\Auth;
use think\Db;
use traits\controller\Jump;

/**
 *  应用处理
 * Class AppMiddeware
 */
class AppMiddeware
{
    use Jump;
    public function handle($request, \Closure $next)
    {
        /**
         * 检测应用访问情况
         */
        $module = get_module();
        $data = get_option("steward_" . $module);
        //放行状态
        if ($data and $data['status'] != 1) $this->error("禁止访问");
        //系统默应用认设置
        $app_file = app_path() . $module . DIRECTORY_SEPARATOR . 'app.json';
        if (file_exists($app_file))
        {
            $data = json_decode(file_get_contents($app_file),true);
            if ($data and $data['status'] != 1) $this->error("禁止访问");
        }
        return $next($request);
    }
}
